In [11]:
!pip install xgboost
Requirement already satisfied: xgboost in /usr/local/lib/python3.10/dist-packages (2.1.2)
Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from xgboost) (1.26.4)
Requirement already satisfied: nvidia-nccl-cu12 in /usr/local/lib/python3.10/dist-packages (from xgboost) (2.23.4)
Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from xgboost) (1.13.1)
In [12]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split, RandomizedSearchCV
from sklearn.preprocessing import StandardScaler, PolynomialFeatures
from sklearn.metrics import r2_score, mean_absolute_error
import xgboost as xgb

# Load data
train_data = pd.read_csv('/content/drive/MyDrive/colab_notebooks/Data/main_dataset.csv')
train_data['Id'] = np.where(train_data['Id'] < 1e-18, 1e-18, train_data['Id'])
train_data['Log_Id'] = np.log10(train_data['Id'])
X = train_data[['Tox', 'Nc', 'Nd', 'Ns', 'Vds', 'Vgs']]
y = train_data['Log_Id']

# Polynomial features and scaling
poly = PolynomialFeatures(degree=3, include_bias=False)
X_poly = poly.fit_transform(X)
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X_poly)
X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, test_size=0.3, random_state=42)

# Define hyperparameter grid for XGBoost
param_grid = {
    'learning_rate': [0.01, 0.05, 0.1],
    'n_estimators': [100, 200, 500],
    'max_depth': [3, 5, 7, 10],
    'min_child_weight': [1, 5, 10],
    'subsample': [0.5, 0.7, 1.0],
    'colsample_bytree': [0.5, 0.7, 1.0],
    'gamma': [0, 0.1, 0.5],
    'reg_lambda': [0, 1, 10],
    'reg_alpha': [0, 0.1, 1]
}

# DataFrame to store results
results_df = pd.DataFrame(columns=['learning_rate', 'n_estimators', 'max_depth', 'min_child_weight',
                                   'subsample', 'colsample_bytree', 'gamma', 'reg_lambda', 'reg_alpha',
                                   'R2', 'MAE'])

random_search = RandomizedSearchCV(
    xgb.XGBRegressor(random_state=42, objective='reg:squarederror'),
    param_grid,
    n_iter=60,
    random_state=42,
    n_jobs=-1,
    verbose=5,
    cv=3
)

random_search.fit(X_train, y_train)
Fitting 3 folds for each of 60 candidates, totalling 180 fits
Out[12]:
RandomizedSearchCV(cv=3,
                   estimator=XGBRegressor(base_score=None, booster=None,
                                          callbacks=None,
                                          colsample_bylevel=None,
                                          colsample_bynode=None,
                                          colsample_bytree=None, device=None,
                                          early_stopping_rounds=None,
                                          enable_categorical=False,
                                          eval_metric=None, feature_types=None,
                                          gamma=None, grow_policy=None,
                                          importance_type=None,
                                          interaction_constraints=None,
                                          learning_rate=...
                                          n_estimators=None, n_jobs=None,
                                          num_parallel_tree=None,
                                          random_state=42, ...),
                   n_iter=60, n_jobs=-1,
                   param_distributions={'colsample_bytree': [0.5, 0.7, 1.0],
                                        'gamma': [0, 0.1, 0.5],
                                        'learning_rate': [0.01, 0.05, 0.1],
                                        'max_depth': [3, 5, 7, 10],
                                        'min_child_weight': [1, 5, 10],
                                        'n_estimators': [100, 200, 500],
                                        'reg_alpha': [0, 0.1, 1],
                                        'reg_lambda': [0, 1, 10],
                                        'subsample': [0.5, 0.7, 1.0]},
                   random_state=42, verbose=5)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
RandomizedSearchCV(cv=3,
                   estimator=XGBRegressor(base_score=None, booster=None,
                                          callbacks=None,
                                          colsample_bylevel=None,
                                          colsample_bynode=None,
                                          colsample_bytree=None, device=None,
                                          early_stopping_rounds=None,
                                          enable_categorical=False,
                                          eval_metric=None, feature_types=None,
                                          gamma=None, grow_policy=None,
                                          importance_type=None,
                                          interaction_constraints=None,
                                          learning_rate=...
                                          n_estimators=None, n_jobs=None,
                                          num_parallel_tree=None,
                                          random_state=42, ...),
                   n_iter=60, n_jobs=-1,
                   param_distributions={'colsample_bytree': [0.5, 0.7, 1.0],
                                        'gamma': [0, 0.1, 0.5],
                                        'learning_rate': [0.01, 0.05, 0.1],
                                        'max_depth': [3, 5, 7, 10],
                                        'min_child_weight': [1, 5, 10],
                                        'n_estimators': [100, 200, 500],
                                        'reg_alpha': [0, 0.1, 1],
                                        'reg_lambda': [0, 1, 10],
                                        'subsample': [0.5, 0.7, 1.0]},
                   random_state=42, verbose=5)
XGBRegressor(base_score=None, booster=None, callbacks=None,
             colsample_bylevel=None, colsample_bynode=None,
             colsample_bytree=0.5, device=None, early_stopping_rounds=None,
             enable_categorical=False, eval_metric=None, feature_types=None,
             gamma=0, grow_policy=None, importance_type=None,
             interaction_constraints=None, learning_rate=0.1, max_bin=None,
             max_cat_threshold=None, max_cat_to_onehot=None,
             max_delta_step=None, max_depth=10, max_leaves=None,
             min_child_weight=1, missing=nan, monotone_constraints=None,
             multi_strategy=None, n_estimators=500, n_jobs=None,
             num_parallel_tree=None, random_state=42, ...)
XGBRegressor(base_score=None, booster=None, callbacks=None,
             colsample_bylevel=None, colsample_bynode=None,
             colsample_bytree=0.5, device=None, early_stopping_rounds=None,
             enable_categorical=False, eval_metric=None, feature_types=None,
             gamma=0, grow_policy=None, importance_type=None,
             interaction_constraints=None, learning_rate=0.1, max_bin=None,
             max_cat_threshold=None, max_cat_to_onehot=None,
             max_delta_step=None, max_depth=10, max_leaves=None,
             min_child_weight=1, missing=nan, monotone_constraints=None,
             multi_strategy=None, n_estimators=500, n_jobs=None,
             num_parallel_tree=None, random_state=42, ...)
In [12]:

In [13]:
# Loop through each hyperparameter set
for params in random_search.cv_results_['params']:
    # Set up the model with the current parameters
    model = xgb.XGBRegressor(random_state=42, **params)
    model.fit(X_train, y_train)
    print(params)

    # Test on the first test dataset
    y_pred_test = model.predict(X_test)
    r2 = r2_score(y_test, y_pred_test)
    mae = mean_absolute_error(y_test, y_pred_test)

    # Load and preprocess the second test data
    test_data = pd.read_csv('/content/drive/MyDrive/colab_notebooks/Data/test_data.csv').iloc[0:203]
    test_data['Id'] = np.where(test_data['Id'] < 1e-18, 1e-18, test_data['Id'])
    test_data['Log_Id'] = np.log10(test_data['Id'])
    X_test_1 = test_data[['Tox', 'Nc', 'Nd', 'Ns', 'Vds', 'Vgs']]
    y_test_1 = test_data['Log_Id']
    X_test_1_transformed = poly.transform(X_test_1)
    X_test_1_scaled = scaler.transform(X_test_1_transformed)

    # Predict on the second test dataset and evaluate
    y_pred_test_1 = model.predict(X_test_1_scaled)
    r2_test_1 = r2_score(y_test_1, y_pred_test_1)
    mae_test_1 = mean_absolute_error(y_test_1, y_pred_test_1)

    # Log scale plot
    plt.figure(figsize=(10, 5))
    plt.plot(X_test_1['Vgs'], y_pred_test_1, color="green", label="Predicted")
    plt.plot(X_test_1['Vgs'], y_test_1, color="blue", label="Actual")
    plt.title(f'Vgs vs Id (Log scale) - Params: {params}')
    plt.xlabel('Vgs')
    plt.ylabel('Log10(Id)')
    plt.legend()
    plt.show()

    # Linear scale plot
    plt.figure(figsize=(10, 5))
    plt.plot(X_test_1['Vgs'], np.maximum(np.power(10, y_pred_test_1), 1e-18), color="green", label="Predicted")
    plt.plot(X_test_1['Vgs'], np.maximum(np.power(10, y_test_1), 1e-18), color="blue", label="Actual")
    plt.title(f'Vgs vs Id (Linear scale) - Params: {params}')
    plt.xlabel('Vgs')
    plt.ylabel('Id')
    plt.legend()
    plt.show()

    current_result = pd.DataFrame({
        'learning_rate': params['learning_rate'],
        'n_estimators': params['n_estimators'],
        'max_depth': params['max_depth'],
        'min_child_weight': params['min_child_weight'],
        'subsample': params['subsample'],
        'colsample_bytree': params['colsample_bytree'],
        'gamma': params['gamma'],
        'reg_lambda': params['reg_lambda'],
        'reg_alpha': params['reg_alpha'],
        'R2': r2_test_1,
        'MAE': mae_test_1
    }, index=[0])

    # Save to DataFrame
    results_df = pd.concat([results_df, current_result], ignore_index=True)

    print("-------------\n-------------------\n---------------\n")
# Display results
print(results_df)
{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 5, 'learning_rate': 0.01, 'gamma': 0.5, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
<ipython-input-13-23f2d83d3468>:62: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.
  results_df = pd.concat([results_df, current_result], ignore_index=True)
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 1, 'max_depth': 5, 'learning_rate': 0.05, 'gamma': 0.5, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 1, 'reg_alpha': 1, 'n_estimators': 200, 'min_child_weight': 5, 'max_depth': 10, 'learning_rate': 0.01, 'gamma': 0, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 10, 'reg_alpha': 0.1, 'n_estimators': 200, 'min_child_weight': 1, 'max_depth': 7, 'learning_rate': 0.1, 'gamma': 0.1, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 200, 'min_child_weight': 10, 'max_depth': 3, 'learning_rate': 0.05, 'gamma': 0.1, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 1, 'reg_alpha': 0, 'n_estimators': 500, 'min_child_weight': 1, 'max_depth': 5, 'learning_rate': 0.01, 'gamma': 0.1, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 10, 'reg_alpha': 1, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 7, 'learning_rate': 0.1, 'gamma': 0, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 1, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 1, 'max_depth': 10, 'learning_rate': 0.05, 'gamma': 0.1, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 200, 'min_child_weight': 10, 'max_depth': 5, 'learning_rate': 0.01, 'gamma': 0.5, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 5, 'learning_rate': 0.1, 'gamma': 0.5, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 10, 'reg_alpha': 1, 'n_estimators': 200, 'min_child_weight': 1, 'max_depth': 7, 'learning_rate': 0.05, 'gamma': 0.1, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 0.1, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 7, 'learning_rate': 0.05, 'gamma': 0.1, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 1, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 10, 'learning_rate': 0.1, 'gamma': 0.1, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 1, 'reg_alpha': 1, 'n_estimators': 100, 'min_child_weight': 10, 'max_depth': 7, 'learning_rate': 0.1, 'gamma': 0, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 1, 'reg_alpha': 0.1, 'n_estimators': 500, 'min_child_weight': 10, 'max_depth': 5, 'learning_rate': 0.05, 'gamma': 0.5, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 10, 'reg_alpha': 0, 'n_estimators': 500, 'min_child_weight': 1, 'max_depth': 7, 'learning_rate': 0.1, 'gamma': 0.5, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 0.1, 'n_estimators': 500, 'min_child_weight': 10, 'max_depth': 7, 'learning_rate': 0.05, 'gamma': 0, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 1, 'reg_alpha': 0.1, 'n_estimators': 200, 'min_child_weight': 1, 'max_depth': 10, 'learning_rate': 0.01, 'gamma': 0, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 1, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 1, 'max_depth': 3, 'learning_rate': 0.01, 'gamma': 0.5, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 1, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 1, 'max_depth': 7, 'learning_rate': 0.1, 'gamma': 0, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 0, 'reg_alpha': 1, 'n_estimators': 200, 'min_child_weight': 10, 'max_depth': 5, 'learning_rate': 0.1, 'gamma': 0.1, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 200, 'min_child_weight': 10, 'max_depth': 3, 'learning_rate': 0.1, 'gamma': 0.1, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 1, 'reg_alpha': 1, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 7, 'learning_rate': 0.01, 'gamma': 0.5, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 1, 'n_estimators': 500, 'min_child_weight': 1, 'max_depth': 3, 'learning_rate': 0.01, 'gamma': 0, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 1, 'reg_alpha': 0.1, 'n_estimators': 200, 'min_child_weight': 1, 'max_depth': 7, 'learning_rate': 0.01, 'gamma': 0.1, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 1, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 5, 'learning_rate': 0.1, 'gamma': 0, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 10, 'reg_alpha': 1, 'n_estimators': 500, 'min_child_weight': 1, 'max_depth': 7, 'learning_rate': 0.01, 'gamma': 0.5, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 10, 'reg_alpha': 1, 'n_estimators': 500, 'min_child_weight': 5, 'max_depth': 10, 'learning_rate': 0.1, 'gamma': 0.5, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 10, 'reg_alpha': 0, 'n_estimators': 500, 'min_child_weight': 5, 'max_depth': 5, 'learning_rate': 0.1, 'gamma': 0.5, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 10, 'reg_alpha': 0.1, 'n_estimators': 500, 'min_child_weight': 10, 'max_depth': 5, 'learning_rate': 0.05, 'gamma': 0, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 1, 'reg_alpha': 0.1, 'n_estimators': 100, 'min_child_weight': 10, 'max_depth': 10, 'learning_rate': 0.01, 'gamma': 0.5, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 10, 'reg_alpha': 0.1, 'n_estimators': 200, 'min_child_weight': 10, 'max_depth': 10, 'learning_rate': 0.01, 'gamma': 0, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 1, 'n_estimators': 500, 'min_child_weight': 1, 'max_depth': 10, 'learning_rate': 0.1, 'gamma': 0, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 0.1, 'n_estimators': 200, 'min_child_weight': 1, 'max_depth': 5, 'learning_rate': 0.1, 'gamma': 0.5, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 200, 'min_child_weight': 10, 'max_depth': 3, 'learning_rate': 0.01, 'gamma': 0, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 10, 'max_depth': 7, 'learning_rate': 0.05, 'gamma': 0, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 10, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 3, 'learning_rate': 0.01, 'gamma': 0.1, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 0.1, 'n_estimators': 500, 'min_child_weight': 5, 'max_depth': 7, 'learning_rate': 0.01, 'gamma': 0.1, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 0.1, 'n_estimators': 200, 'min_child_weight': 10, 'max_depth': 10, 'learning_rate': 0.05, 'gamma': 0, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 10, 'reg_alpha': 0, 'n_estimators': 500, 'min_child_weight': 1, 'max_depth': 10, 'learning_rate': 0.01, 'gamma': 0.5, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 10, 'reg_alpha': 1, 'n_estimators': 200, 'min_child_weight': 1, 'max_depth': 5, 'learning_rate': 0.05, 'gamma': 0, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 0.1, 'n_estimators': 100, 'min_child_weight': 10, 'max_depth': 5, 'learning_rate': 0.01, 'gamma': 0, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 500, 'min_child_weight': 10, 'max_depth': 7, 'learning_rate': 0.1, 'gamma': 0, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 0, 'reg_alpha': 1, 'n_estimators': 500, 'min_child_weight': 5, 'max_depth': 7, 'learning_rate': 0.01, 'gamma': 0.1, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 1, 'max_depth': 3, 'learning_rate': 0.05, 'gamma': 0.1, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 0.1, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 3, 'learning_rate': 0.01, 'gamma': 0, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 1, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 10, 'max_depth': 10, 'learning_rate': 0.1, 'gamma': 0.1, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 10, 'reg_alpha': 0.1, 'n_estimators': 500, 'min_child_weight': 5, 'max_depth': 5, 'learning_rate': 0.05, 'gamma': 0.1, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 10, 'reg_alpha': 0.1, 'n_estimators': 100, 'min_child_weight': 10, 'max_depth': 10, 'learning_rate': 0.05, 'gamma': 0, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 10, 'reg_alpha': 0.1, 'n_estimators': 200, 'min_child_weight': 1, 'max_depth': 3, 'learning_rate': 0.01, 'gamma': 0, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 10, 'reg_alpha': 1, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 10, 'learning_rate': 0.05, 'gamma': 0, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 1, 'n_estimators': 200, 'min_child_weight': 1, 'max_depth': 7, 'learning_rate': 0.05, 'gamma': 0, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 0.1, 'n_estimators': 100, 'min_child_weight': 10, 'max_depth': 7, 'learning_rate': 0.1, 'gamma': 0.5, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 200, 'min_child_weight': 1, 'max_depth': 7, 'learning_rate': 0.05, 'gamma': 0, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.5, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 5, 'learning_rate': 0.1, 'gamma': 0, 'colsample_bytree': 0.7}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 0, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 7, 'learning_rate': 0.01, 'gamma': 0.5, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 1, 'n_estimators': 100, 'min_child_weight': 10, 'max_depth': 7, 'learning_rate': 0.1, 'gamma': 0, 'colsample_bytree': 0.5}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 10, 'reg_alpha': 0.1, 'n_estimators': 100, 'min_child_weight': 5, 'max_depth': 3, 'learning_rate': 0.01, 'gamma': 0.5, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 0.7, 'reg_lambda': 0, 'reg_alpha': 1, 'n_estimators': 100, 'min_child_weight': 10, 'max_depth': 7, 'learning_rate': 0.1, 'gamma': 0.5, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

{'subsample': 1.0, 'reg_lambda': 0, 'reg_alpha': 1, 'n_estimators': 100, 'min_child_weight': 1, 'max_depth': 5, 'learning_rate': 0.1, 'gamma': 0.1, 'colsample_bytree': 1.0}
No description has been provided for this image
No description has been provided for this image
-------------
-------------------
---------------

    learning_rate n_estimators max_depth min_child_weight  subsample  \
0            0.01          100         5                5        1.0   
1            0.05          100         5                1        0.5   
2            0.01          200        10                5        1.0   
3            0.10          200         7                1        1.0   
4            0.05          200         3               10        1.0   
5            0.01          500         5                1        0.5   
6            0.10          100         7                5        0.7   
7            0.05          100        10                1        1.0   
8            0.01          200         5               10        0.7   
9            0.10          100         5                5        1.0   
10           0.05          200         7                1        0.7   
11           0.05          100         7                5        1.0   
12           0.10          100        10                5        1.0   
13           0.10          100         7               10        1.0   
14           0.05          500         5               10        0.5   
15           0.10          500         7                1        0.5   
16           0.05          500         7               10        1.0   
17           0.01          200        10                1        0.7   
18           0.01          100         3                1        1.0   
19           0.10          100         7                1        0.5   
20           0.10          200         5               10        0.7   
21           0.10          200         3               10        1.0   
22           0.01          100         7                5        0.5   
23           0.01          500         3                1        0.5   
24           0.01          200         7                1        1.0   
25           0.10          100         5                5        1.0   
26           0.01          500         7                1        0.5   
27           0.10          500        10                5        1.0   
28           0.10          500         5                5        1.0   
29           0.05          500         5               10        0.5   
30           0.01          100        10               10        1.0   
31           0.01          200        10               10        1.0   
32           0.10          500        10                1        1.0   
33           0.10          200         5                1        0.5   
34           0.01          200         3               10        0.5   
35           0.05          100         7               10        1.0   
36           0.01          100         3                5        1.0   
37           0.01          500         7                5        0.5   
38           0.05          200        10               10        0.5   
39           0.01          500        10                1        0.7   
40           0.05          200         5                1        0.7   
41           0.01          100         5               10        1.0   
42           0.10          500         7               10        0.5   
43           0.01          500         7                5        0.7   
44           0.05          100         3                1        1.0   
45           0.01          100         3                5        0.5   
46           0.10          100        10               10        0.5   
47           0.05          500         5                5        0.5   
48           0.05          100        10               10        0.7   
49           0.01          200         3                1        1.0   
50           0.05          100        10                5        0.7   
51           0.05          200         7                1        1.0   
52           0.10          100         7               10        0.5   
53           0.05          200         7                1        0.5   
54           0.10          100         5                5        0.5   
55           0.01          100         7                5        1.0   
56           0.10          100         7               10        1.0   
57           0.01          100         3                5        0.7   
58           0.10          100         7               10        0.7   
59           0.10          100         5                1        1.0   

    colsample_bytree  gamma reg_lambda reg_alpha        R2       MAE  
0                1.0    0.5          0         0  0.495697  3.019956  
1                0.7    0.5          0         0  0.990589  0.193651  
2                0.5    0.0          1         1  0.934526  1.036125  
3                0.5    0.1         10       0.1  0.990803  0.216194  
4                1.0    0.1          0         0  0.991262  0.221330  
5                0.7    0.1          1         0  0.990016  0.203315  
6                0.7    0.0         10         1  0.991737  0.208715  
7                1.0    0.1          1         0  0.987646  0.208109  
8                0.5    0.5          0         0  0.930100  1.063564  
9                0.7    0.5          0         0  0.989541  0.226556  
10               0.5    0.1         10         1  0.990450  0.216639  
11               1.0    0.1          0       0.1  0.991126  0.182416  
12               0.7    0.1          1         0  0.988764  0.252684  
13               0.7    0.0          1         1  0.990580  0.220029  
14               0.7    0.5          1       0.1  0.990434  0.235250  
15               0.5    0.5         10         0  0.990999  0.238979  
16               0.5    0.0          0       0.1  0.991159  0.227087  
17               0.5    0.0          1       0.1  0.933749  1.043032  
18               1.0    0.5          1         0  0.440930  3.148068  
19               0.5    0.0          1         0  0.991471  0.204066  
20               0.5    0.1          0         1  0.991145  0.191299  
21               0.5    0.1          0         0  0.991720  0.199464  
22               0.5    0.5          1         1  0.497885  3.029735  
23               1.0    0.0          0         1  0.985794  0.345139  
24               1.0    0.1          1       0.1  0.934976  1.043258  
25               1.0    0.0          1         0  0.990357  0.242413  
26               0.5    0.5         10         1  0.990911  0.178247  
27               0.5    0.5         10         1  0.989607  0.209029  
28               1.0    0.5         10         0  0.991028  0.245704  
29               1.0    0.0         10       0.1  0.990014  0.246782  
30               1.0    0.5          1       0.1  0.504115  2.994305  
31               1.0    0.0         10       0.1  0.934498  1.034423  
32               0.5    0.0          0         1  0.990747  0.205042  
33               1.0    0.5          0       0.1  0.990002  0.247336  
34               0.5    0.0          0         0  0.898824  1.256610  
35               1.0    0.0          0         0  0.991180  0.187595  
36               0.5    0.1         10         0  0.422951  3.215910  
37               1.0    0.1          0       0.1  0.990484  0.191334  
38               0.5    0.0          0       0.1  0.988725  0.240182  
39               1.0    0.5         10         0  0.988625  0.191900  
40               0.5    0.0         10         1  0.991252  0.227508  
41               1.0    0.0          0       0.1  0.495531  3.020980  
42               0.7    0.0          0         0  0.991813  0.190924  
43               0.5    0.1          0         1  0.991101  0.177922  
44               0.5    0.1          0         0  0.987373  0.324073  
45               0.7    0.0          0       0.1  0.436521  3.169234  
46               0.7    0.1          1         0  0.989759  0.232282  
47               1.0    0.1         10       0.1  0.989640  0.249124  
48               0.7    0.0         10       0.1  0.990173  0.181991  
49               0.7    0.0         10       0.1  0.902885  1.219944  
50               0.7    0.0         10         1  0.990596  0.175469  
51               0.7    0.0          0         1  0.990910  0.214815  
52               0.5    0.5          0       0.1  0.990541  0.204696  
53               0.7    0.0          0         0  0.991431  0.218027  
54               0.7    0.0          0         0  0.990883  0.246040  
55               1.0    0.5          0         0  0.500744  3.014904  
56               0.5    0.0          0         1  0.991731  0.208399  
57               1.0    0.5         10       0.1  0.441253  3.148014  
58               1.0    0.5          0         1  0.989877  0.240173  
59               1.0    0.1          0         1  0.990478  0.245975  
In [14]:
from google.colab import drive
drive.mount('/content/drive')
Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount("/content/drive", force_remount=True).
In [15]:
results_df.to_csv('xg_hyP_tuning_results.csv', index=False)